package com.wgke.bluetooth.vm;

import android.bluetooth.BluetoothDevice;
import android.util.Log;

import androidx.lifecycle.MutableLiveData;

import com.wgke.bluetooth.tools.GattServiceBean;
import com.wgke.bluetooth.utils.BluetoothGattManager;

import java.util.ArrayList;
import java.util.List;

public class ConnectVM extends BaseVM {

    public MutableLiveData<String> title = new MutableLiveData<>("");
    public MutableLiveData<List<GattServiceBean>> list = new MutableLiveData<>(new ArrayList<>());

    public void scanService() {
        if (null == BluetoothGattManager.getInstance().getGatt()){
            Log.e("ConnectVM", "scanService: gatt is null");
            return;
        }
        if (null == BluetoothGattManager.getInstance().getServices()){
            Log.e("ConnectVM", "scanService: services is null");
            return;
        }
        BluetoothGattManager bm = BluetoothGattManager.getInstance();
        list.postValue(bm.handleData(bm.getServices()));
    }
}
